<!--
  Copyright 2013-2018 the original author or authors.

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<div ng-include src="'template/gt-loading-overlay.html'"></div>
<div ng-include src="'template/gt-http-error-overlay.html'"></div>
<div ng-if="agentNotConnected" class="alert alert-danger" role="alert">
  This feature is only available when the agent is running and connected
</div>
<!-- intentionally not using gt-form-with-primary-button to prevent accidental heap dumps -->
<div ng-form
     gt-form-autofocus-on-first-input
     name="formCtrl"
     ng-if="loaded && !agentNotConnected"
     style="margin-top: 10px;">
  <div class="form-group row">
    <label class="col-form-label col-md-2 text-right" for="directory">
      Directory
    </label>
    <!-- col-md-9 instead of col-md-10 in order to leave a bit of padding to the right -->
    <div class="col-md-9">
      <input type="text"
             class="form-control"
             ng-model="page.directory"
             id="directory"
             name="directory">
      <div class="help-block">
        Use the jvm arg <code style="white-space: nowrap;">-XX:HeapDumpPath=&lt;directory&gt;</code>
        to change the default heap dump location.
      </div>
    </div>
  </div>
  <div class="form-group row">
    <div class="offset-md-2 col-md-10">
      <div gt-button-group>
        <div gt-button
             gt-btn-class="btn-danger"
             gt-label="Heap dump"
             gt-click="heapDump(deferred)"
             gt-confirm-header="Perform heap dump?"
             gt-confirm-body="Note: This may hang the JVM for a bit while the heap dump is generated."
             class="d-inline-block">
        </div>
        <div gt-button
             gt-label="Check disk space"
             gt-click="checkDiskSpace(deferred)"
             gt-btn-class="btn-secondary"
             class="d-inline-block">
        </div>
      </div>
    </div>
  </div>
  <!-- checking against undefined so it will still show when availableDiskSpaceBytes === 0 -->
  <div class="form-group row"
       ng-if="availableDiskSpaceBytes !== undefined">
    <div class="col-md-offset-2 col-md-9">
      <div class="well">
        <table class="gt-heap-dump-response">
          <tr>
            <td>Free disk space</td>
            <td><strong>{{availableDiskSpaceBytes | gtBytes}}</strong></td>
          </tr>
        </table>
      </div>
    </div>
  </div>
  <div class="form-group row"
       ng-if="heapDumpResponse">
    <div class="col-md-offset-2 col-md-9">
      <div class="well">
        <table class="gt-heap-dump-response">
          <tr>
            <td class="gt-nowrap">Heap dump</td>
            <!-- break-all is for long paths with no spaces or hyphens -->
            <td><strong style="word-break: break-all;">{{heapDumpResponse.filePath}}</strong></td>
          </tr>
          <tr>
            <td class="gt-nowrap">File size</td>
            <td><strong>{{heapDumpResponse.fileSizeBytes | gtBytes}}</strong></td>
          </tr>
        </table>
      </div>
    </div>
  </div>
</div>
<!-- each page with confirmation dialog needs its own confirmation dom so that it is deleted on $destroy -->
<div ng-include="'template/gt-confirmation.html'"></div>
